package com.zmn.oms.zmn.normal.business.interfaces.refund;

import com.zmn.oms.common.dro.normal.master.ReworkRefundDRO;
import com.zmn.oms.common.dto.OmsOperator;
import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.model.bo.work.review.RefundReviewBO;
import com.zmn.oms.model.dto.finalprice.RefundDifferenceDTO;
import com.zmn.oms.model.dto.order.pay.DuplicatePayRefundDTO;
import com.zmn.oms.model.dro.refund.RefundBacktrackingAmountDRO;
import com.zmn.oms.model.dto.order.pay.RefundResultDTO;
import com.zmn.oms.model.dto.work.refund.RefundApplyDTO;
import com.zmn.oms.model.dto.work.refund.RefundDTO;
import com.zmn.oms.model.entity.pay.OrderPay;
import com.zmn.oms.model.entity.refund.OrderWorkRefund;
import com.zmn.oms.model.entity.work.OrderWork;
import com.zmn.oms.model.vo.work.refund.RefundVO;
import com.zmn.pay.gateway.common.model.dro.RefundResultDRO;

import java.util.List;

/**
 * 类描述：退款
 * @author heciqi
 * @date 2019/8/9 16:44
 */
public interface RefundBService {

	/**
	 * 申请退款
	 * @param refundApplyDTO
	 */
	void applyRefund(RefundApplyDTO refundApplyDTO) throws OmsBaseException;

	/**
	 * 提交退款
	 * @param refundDTO
	 */
	OrderWork commitRefund(RefundDTO refundDTO) throws Exception;

	/**
	 * 重复支付提交退款
	 * @param dto
	 */
	void duplicatePayRefund(RefundResultDTO dto);

	/**
	 * 是否支持原路返回
	 * @param orderId
	 * @return
	 */
	boolean supportBacktracking(Long orderId);

	/**
	 * 修改退款结果
	 *
	 * @param refundResultDRO
	 */
	void updateRefundResult(RefundResultDRO refundResultDRO);

	/**
	 * 修改退款结果（新的）
	 *
	 * @param refundResultDRO
	 */
	void updateNewRefundResult(RefundResultDRO refundResultDRO);

	/**
	 * 修改退款结果（新的）
	 *
	 * @param refundResultDRO
	 */
	void updateTimesCardWorkRefundResult(RefundResultDRO refundResultDRO);

	/**
	 * 提交退款
	 * @param orderWork
	 * @param refundAmount
	 */
	List<OrderWorkRefund> distriRefundAmount(OrderWork orderWork, Integer refundAmount) throws OmsBaseException;

	/**
	 * 获取退款单vo
	 * @param orderId
	 * @param workId
	 * @param isUpdate 是否修改操作
	 * @return
	 */
	RefundVO getRefundVO(Long orderId, Long workId, boolean isUpdate) throws OmsBaseException;

	/**
	 * 退款取消
	 * @param dbOrderWork
	 * @param omsOperator
	 */
    void refundOrderCancel(OrderWork dbOrderWork, OmsOperator omsOperator) throws OmsBaseException;

    OrderWork updateRefund(RefundDTO refundDTO) throws OmsBaseException;

	/**
	 * 退款审批完成
	 */
	void refundReviewComplete(RefundReviewBO refundReviewBO) throws OmsBaseException;

	/**
	 * 获取返修退款配置
	 * @param orderId
	 * @param workId
	 * @return
	 */
	ReworkRefundDRO getReworkRefundConfig(Long orderId, Long workId) throws OmsBaseException;

	/**
	 * 退款差额
	 * @param refundDifferenceDTO
	 * @throws OmsBaseException
	 */
	void refundDifference(RefundDifferenceDTO refundDifferenceDTO) throws OmsBaseException;

	/**
	 * 差额退款回调
	 * @param refundResultDRO
	 */
	void differenceRefundCallback(RefundResultDRO refundResultDRO);

	/**
	 * 获取原路退信息
	 *
	 * @param orderId              原单号
	 * @param discountPrepayAmount 次卡金额
	 * @param orderPays            原单支付记录
	 * @return
	 * @throws OmsBaseException
	 */
	RefundBacktrackingAmountDRO getBackTracking(Long orderId, Integer discountPrepayAmount, List<OrderPay> orderPays) throws OmsBaseException;
}
